package android.FiltrosJava;

public class ColorReplace60 extends PointFilter{
	/*protected static int [][] cores18 = {
		{255, 255, 255},
		{253, 226, 73},
		{250, 178, 42},
		{228, 90, 27},
		{227, 0, 17},
		{226, 0, 63},
		{220, 0, 129},
		{43, 18, 109},
		{38, 28, 101},
		{7, 116, 159},
		{4, 166, 151},
		{11, 126, 119},
		{0, 156, 79},
		{164, 192, 72},
		{198, 0, 22},
		{95, 12, 28},
		{30, 12, 10},
		{115, 115, 115}
		};
	protected static int[][] cores48 = {
		{255,128,128},
		{255,255,128},
		{128,255,128},
		{0,255,128},
		{128,255,255},
		{0,128,255},
		{255,128,192},
		{255,128,255},
		{255,0,0},
		{255,255,0},
		{128,255,0},
		{0,255,64},
		{0,255,255},
		{0,128,192},
		{128,128,192},
		{255,0,255},
		{128,64,64},
		{255,128,64},
		{0,255,0},
		{0,128,128},
		{0,64,128},
		{128,128,255},
		{128,0,64},
		{255,0,128},
		{128,0,0},
		{255,128,0},
		{0,128,0},
		{0,128,64},
		{0,0,255},
		{0,0,160},
		{128,0,128},
		{128,0,255},
		{64,0,0},
		{128,64,0},
		{0,64,0},
		{0,64,64},
		{0,0,128},
		{0,0,64},
		{64,0,64},
		{64,0,128},
		{0,0,0},
		{128,128,0},
		{128,128,64},
		{128,128,128},
		{64,128,128},
		{192,192,192},
		{64,0,64},
		{255,255,255}
	};
	*/
	protected int[][] cores60 = {
			{0,0,0},
			{255,0,0},
			{255,255,0},
			{0,255,0},
			{0,255,255},
			{0,0,255},
			{255,0,255},
			{255,255,255},
			{215,215,215},
			{149,149,149},
			{137,137,137},
			{85,85,85},
			{246,151,122},
			{253,197,137},
			{255,247,153},
			{196,223,155},
			{130,202,156},
			{123,204,200},
			{110,207,246},
			{126,167,216},
			{132,147,202},
			{136,130,190},
			{161,135,190},
			{188,140,191},
			{244,154,194},
			{245,152,157},
			{242,101,34},
			{247,148,29},
			{141,198,63},
			{0,166,80},
			{0,169,157},
			{0,173,239},
			{0,114,188},
			{0,84,166},
			{46,48,146},
			{102,44,145},
			{146,39,143},
			{236,0,140},
			{237,20,91},
			{121,0,0},
			{123,46,0},
			{125,73,0},
			{130,122,0},
			{64,102,24},
			{0,88,38},
			{0,89,82},
			{0,91,127},
			{0,54,99},
			{0,33,87},
			{13,0,76},
			{50,0,75},
			{75,0,73},
			{123,0,70},
			{121,0,38},
			{199,178,153},
			{115,98,87},
			{54,47,45},
			{197,156,109},
			{140,98,57},
			{96,57,19}
	};
	/*
	protected int[][] cores27 = {
			{0,0,0},
			{176,35,43},
			{0,72,110},
			{86,90,93},
			{217,31,42},
			{1,96,162},
			{195,200,204},
			{255,114,0},
			{64,189,233},
			{255,255,255},
			{253,198,69},
			{190,217,238},
			{218,191,222},
			{254,220,1},
			{170,230,204},
			{126,9,150},
			{241,235,123},
			{165,215,104},
			{254,162,139},
			{237,213,175},
			{0,132,119},
			{224,33,137},
			{207,170,125},
			{0,119,74},
			{117,39,65},
			{108,71,18},
			{24,70,44}
	};
	*/
	protected int [][] cores = cores60;
	/*public void set18Cores(){
		cores = cores18;
	}
	
	public void set27Cores(){
		cores = cores27;
	}
	
	public void set48Cores(){
		cores = cores48;
	}
	
	public void set60Cores(){
		cores = cores60;
	}
	*/
	public int[] computeFilter(int px, int py, int[] imageData){
		int d = 195075;
		int d1, dr, dg, db, escolha;
		int N = cores.length;
		escolha = 0;
		for (int y = 0; y < N; y++){
			dr = (imageData[0] - cores[y][0]);
			dg = (imageData[1] - cores[y][1]);
			db = (imageData[2] - cores[y][2]);
			d1 = dr * dr + dg * dg + db * db;
			if (d1 < d){
				d = d1;
				escolha = y;
			}				
		}
		imageData[0] = cores[escolha][0];
		imageData[1] = cores[escolha][1];
		imageData[2] = cores[escolha][2];
					
		return imageData;
	}
	@Override
	public int[] applyFilter(int[] pixels) {
		// TODO Auto-generated method stub
		return null;
	}	
}
